<?php

namespace App\Library\Logs;

use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler as RotatingBase;

class RotatingFileHandler extends RotatingBase
{
    protected function getTimedFilename()
    {
        $fileInfo = pathinfo($this->filename);
        if ($fileInfo['filename']=='_') {
            $filename = 'defalt';
        }else{
            $filename = $fileInfo['filename'];
        }

        $timedFilename = str_replace(
            array('{filename}', '{date}'),
            array($fileInfo['filename'], date($this->dateFormat)),
            $fileInfo['dirname'] . '/'.$filename
        );

        if (!empty($fileInfo['extension'])) {
            $timedFilename .= '.'.$fileInfo['extension'];
        }

        return $timedFilename;
    }
}